package com.jkc.xh.adapters.viewholder;

import android.content.Context;
import android.util.AttributeSet;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.jkc.xh.R;
import com.jkc.xh.models.RedbagModel;
import com.jkc.xh.utils.Tool;

import org.androidannotations.annotations.EViewGroup;
import org.androidannotations.annotations.ViewById;

/**
 * Created by wangjie28 on 2015/11/13.
 */
@EViewGroup(R.layout.item_reg_bag)
public class RedbagItemView extends RelativeLayout {


    @ViewById(R.id.amount)
    TextView amount;

    @ViewById(R.id.status)
    TextView status;

    @ViewById(R.id.remark)
    TextView remark;

    @ViewById(R.id.giver_uname)
    TextView giver_uname;

    @ViewById(R.id.create_time)
    TextView create_time;

    @ViewById
    ImageView itemTypeIcon;

    public RedbagItemView(Context context) {
        super(context);
    }

    public RedbagItemView(Context context, AttributeSet attrs) {
        super(context, attrs);
    }


    public void bind(RedbagModel model) {
        amount.setText(model.amount + "元");
        status.setText(model.type + model.getStatus());
        remark.setText(model.remark);
        giver_uname.setText(model.giver_uname);
        create_time.setText(Tool.formatSecondSimpleFullDate(model.create_time));
        if(model.isOpen()){
            itemTypeIcon.setImageResource(R.drawable.icon_redbag);
        }else{
            itemTypeIcon.setImageResource(R.drawable.redbag_close);
        }
    }


}
